package com.handmark.pulltorefresh.library;

import com.ss.android.article.base.feature.feed.activity.ArticleRecentFragment;

public final class OverscrollHelper {
    private final ArticleRecentFragment mArticleRecentFragment;

    public OverscrollHelper(ArticleRecentFragment articleRecentFragment) {
        this.mArticleRecentFragment = articleRecentFragment;
    }

    public final void overScrollBy(int arg2, int arg3) {
        if (arg2 > 0 && arg3 >= 0 && this.mArticleRecentFragment.mListView != null && this.mArticleRecentFragment.mListView.getFirstVisiblePosition() > 0 && !this.mArticleRecentFragment.getData().isEmpty()) {
            this.mArticleRecentFragment.onScrollBottom();
        }
    }

    public static void overScrollBy(PullToRefreshBase arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11, float arg12, boolean arg13) {
        int v3;
        int v0;
        int v1 = 1;
        switch (arg5.getPullToRefreshScrollDirection()) {
            case HORIZONTAL:
                v0 = arg5.getScrollX();
                break;
            default:
                v0 = arg5.getScrollY();
                arg7 = arg9;
                arg6 = arg8;
                break;
        }

        if (arg5.mOverScrollEnabled) {
            v3 = arg5.mRefreshableView.getOverScrollMode() != 2 ? 1 : 0;
            if (v3 == 0) {
                v1 = 0;
            }
        } else {
            v1 = 0;
        }

        if (v1 != 0 && !arg5.c()) {
            PullToRefreshBase.Mode v1_1 = arg5.getMode();
            if ((v1_1.permitsPullToRefresh()) && !arg13 && arg6 != 0) {
                v3 = arg6 + arg7;
                if (v3 >= -arg11) {
                    if (v3 > arg10 + arg11) {
                        if (!v1_1.showFooterLoadingLayout()) {
                            return;
                        }

                        if (v0 == 0) {
                            arg5.a(PullToRefreshBase.State.OVERSCROLLING, new boolean[0]);
                        }

                        arg5.setHeaderScroll(((int) ((((float) (v0 + v3 - arg10))) * arg12)));
                        return;
                    }

                    if (Math.abs(v3) > arg11 && Math.abs(v3 - arg10) > arg11) {
                        return;
                    }

                    arg5.a(PullToRefreshBase.State.RESET, new boolean[0]);
                } else if (v1_1.showHeaderLoadingLayout()) {
                    if (v0 == 0) {
                        arg5.a(PullToRefreshBase.State.OVERSCROLLING, new boolean[0]);
                    }

                    arg5.setHeaderScroll(((int) ((((float) (v0 + v3))) * arg12)));
                } else {
                }

                return;
            }

            if (!arg13) {
                return;
            }

            if (PullToRefreshBase.State.OVERSCROLLING != arg5.getState()) {
                return;
            }

            arg5.a(PullToRefreshBase.State.RESET, new boolean[0]);
        }
    }
}

